package com.sphd.emanu.activity.commoditypvsum;

import android.content.Intent;
import android.os.Bundle;
import android.support.v7.widget.Toolbar;
import android.widget.TextView;

import com.sphd.emanu.R;
import com.sphd.emanu.config.Constant;
import com.sphd.emanu.mvp.MVPBaseActivity;
import com.sphd.emanu.pojo.goods.Commodity;
import com.sphd.emanu.pojo.goods.PvSum;

import butterknife.BindView;
import butterknife.ButterKnife;

/**
 * todo 商品的点击次数
 *
 * @Author Hu
 * @Time 2017/7/26 -- 21:39.
 * @Email 87683202@qq.com
 */
public class CommodityPvSumActivity extends MVPBaseActivity<CommodityPvSumContract.View, CommodityPvSumPresenter> implements CommodityPvSumContract.View {
    Intent intent;
    Bundle bundle;
    Commodity commodity;
    @BindView(R.id.toolbar)
    Toolbar toolbar;
    @BindView(R.id.today_sum)
    TextView todaySum;
    @BindView(R.id.yestaday_sum)
    TextView yestadaySum;
    @BindView(R.id.nowmonth_sum)
    TextView nowmonthSum;
    @BindView(R.id.lastmonth_sum)
    TextView lastmonthSum;
    @BindView(R.id.nowyear_sum)
    TextView nowyearSum;
    @BindView(R.id.lastyear_sum)
    TextView lastyearSum;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_commodity_pv_sum);
        ButterKnife.bind(this);
        initView();
        initEvent();
    }

    private void initEvent() {
        toolbar.setNavigationOnClickListener(v -> finish());
    }

    private void initView() {
        intent = getIntent();
        bundle = intent.getExtras();
        commodity = (Commodity) bundle.getSerializable(Constant.COMMODITY);
        setTitleBar(toolbar,commodity.getName());
        addData();
    }

    private void addData() {
        showProgressDialog();
        mPresenter.commodityPvSum(commodity.getId());
    }

    @Override
    public void setBean(PvSum pvSum) {
        dissProgressDialog();
        todaySum.setText(String.valueOf(pvSum.getTodaySum()));
        yestadaySum.setText(String.valueOf(pvSum.getYesterdaySum()));
        nowmonthSum.setText(String.valueOf(pvSum.getMonthSum()));
        lastmonthSum.setText(String.valueOf(pvSum.getLastMonthSum()));
        nowyearSum.setText(String.valueOf(pvSum.getYearSum()));
        lastyearSum.setText(String.valueOf(pvSum.getLastYearSum()));

    }
}
